<?php
/**
 * Created by PhpStorm.
 * User: 18879810386
 * Date: 2016/10/30
 * Time: 17:11
 */header('content-type:text;charset:utf-8');
require './function.php';
dbinit();
$e_id=isset($GET['e_id'])? intval($_GET['e_id']):0;
if(!empty($_POST)) {
    $update = array();
    $friends = array('e_name', 'e_dept', 'date_of_birth', 'date_of_entry');
    foreach ($friends as $v) {
        $data = isset($_POST[$v]) ? $_POST[$v] : '';
        if ($data == '') die('字段不能为空');
$data = safeHandle($data);
$update = "`$v`='$data'";}
$update_str=implode(',',$update);
$sql="update `emp_info` set $update_str where `e_id`=$e_id";
if ($res=query($sql)){
    header("Location:./showlist.php");
    
}else{die('员工信息修改失败')}
}else{$sql="select*from `emp_info` where `e_id`=$e_id";
$emp_info=fetchrow($sql);
define('APP','itcast');
    require './update_html.php';
}